package com.tjetc.dao.impl;

import com.tjetc.dao.AdminRoleDao;
import com.tjetc.domain.AdminRole;
import com.tjetc.utils.Db;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class AdminRoleDaoImpl implements AdminRoleDao {
    @Override
    public AdminRole getByAid(int aid) throws SQLException {
        return Db.runner0().query("select * from admin_role where aid = ?",new BeanHandler<>(AdminRole.class),aid);
    }

    @Override
    public int add(AdminRole adminRole) throws SQLException {
        return Db.runner().update(Db.getConnection(),"insert into admin_role(aid, rid) values (?,?)",
                adminRole.getAid(),adminRole.getRid());
    }
}
